package com.zbcz.crm.util

import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale

const val DATE_FORMAT = "yyyy年MM月dd日"
const val UPLOAD_FORMAT = "yyyy-MM-dd"
const val UPLOAD_FORMAT_WHOLE = "yyyy-MM-dd HH:mm:s"
fun formatDate(
    year: Int,
    month: Int,
    dayOfMonth: Int,
    formatPattern: String = DATE_FORMAT
): String? {
    val calendar = Calendar.getInstance()
    calendar[year, month] = dayOfMonth
    val sdf = SimpleDateFormat(formatPattern, Locale.getDefault())
    return sdf.format(calendar.time)
}

fun getCurrentDateFormatted(formatPattern: String = DATE_FORMAT): String? {
    val calendar = Calendar.getInstance()
    val sdf = SimpleDateFormat(formatPattern, Locale.getDefault())
    return sdf.format(calendar.time)
}